<?php
//dezend by http://www.yunlu99.com/ QQ:270656184
defined('BASEPATH') || exit('No direct script access allowed');
?>
<div class="item-content">
	<div class="discuss-form">
		<form action="<?php echo site_url('items/discuss_insert');?>" method="post" id="form_id">
			<input type="hidden" name="item_id" value="<?php echo $id;?>">
			<div class="discuss-textarea"><textarea name="content" must="1"></textarea><p>请输入讨论内容</p></div>
			<div style="text-align:right" class="warning"></div>
			<button type="submit">发布</button>
			<div class="clear"></div>
		</form>
		<script type="text/javascript">
		$(function(){
			$('#form_id').checkForm();
		});
		</script>
	</div>
	
<?php
foreach ($list as $v) {
?>	<div class="discuss-item">
		<div class="discuss-img">
		</div>
		<div class="discuss-txt">
			<div class="discuss-tit">
				<label><?php echo $v['user']['username'];?></label>
				<span><?php echo date('Y-m-d', $v['add_time']);?></span>
			</div>
			<div class="discuss-info">
				
<?php
	if (isset($v['reply'])) {
?>				<div class="discuss-reply">
				<p>@ <?php echo $v['reply']['user']['username'];?></p>
				<label>回复<?php echo $v['user']['username'];?>：</label><?php echo $v['reply']['content'];?>				</div>
				回复<?php echo $v['reply']['user']['username'];?>：<?php echo $v['content'];?>				<?php
	}
	else {
?>				<?php echo $v['content'];?>				<?php
	}

?>			</div>
			
			<a href="javascript:void(0);" reply="reply<?php echo $v['id'];?>"><i class="fa fa-mail-forward"></i> 回复</a>
		</div>
		<div class="clear"></div>
	</div>
	<div class="discuss-form" style="display:none;" id="reply<?php echo $v['id'];?>">
		回复<?php echo $v['user']['username'];?>：
		<form action="<?php echo site_url('items/discuss_insert');?>" method="post" id="form_id<?php echo $v['id'];?>">
			<input type="hidden" name="reply_id" value="<?php echo $v['id'];?>">
			<input type="hidden" name="item_id" value="<?php echo $v['item_id'];?>">
			<div class="discuss-textarea"><textarea name="content" must="1"></textarea><p>请输入讨论内容</p></div>
			<div style="text-align:right" class="warning"></div>
			<button type="submit">回复</button>
			<div class="clear"></div>
		</form>
		<script type="text/javascript">
		$(function(){
			$('#form_id<?php echo $v['id'];?>').checkForm();
		});
		</script>
	</div>
	<?php
}

?>	<div class="page">
	  <?php echo $page;?>	</div>
	
<?php
if (!$list) {
?>	<div class="not-list">
		<i class="fa fa-ban"></i>
		<span><?php echo lang('user_not_list');?></span>
	</div>
	<?php
}

?></div>
<script>
$(function(){
	$('[reply]').click(function(){
		$('#'+$(this).attr('reply')).show();
	});
});
</script>